package com.qf.util;

import com.alibaba.druid.pool.DruidDataSource;
import org.apache.taglibs.standard.tag.common.sql.DataSourceUtil;

import javax.sql.DataSource;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author a1275872671
 * @version v1.0
 * @project guanqipeng
 * @package com.qf.util
 * @company
 * @date 2024/4/30 09:20
 */
public class DatasoureUtil {
    private static DruidDataSource dataSource=new DruidDataSource();
    static {
        try {
            ClassLoader classLoader = DataSourceUtil.class.getClassLoader();
            InputStream is = classLoader.getResourceAsStream("db.properties");
            Properties properties=new Properties();
            properties.load(is);
            is.close();
            dataSource.configFromPropety(properties);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public static DataSource getDataSource(){
        return dataSource;

    }
}
